package pl.edu.pk.mech.kkbus.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.security.core.context.SecurityContextHolder;
        
@Controller
@RequestMapping("/")
public class HomeController {
    
    @RequestMapping(method = RequestMethod.GET)
    public String showHomePage(ModelMap model) {

        String principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
        model.addAttribute("isAuthenticated", principal.equals("anonymousUser") ? false : true);
        
        return "home";
    }
}
